//
//  ResultViewController.m
//  LiuHeBao
//
//  Created by zr on 2018/8/23.
//  Copyright © 2018年 zr. All rights reserved.
//

#import "ResultViewController.h"

@interface ResultViewController ()

@property (nonatomic, weak)UILabel * titleLabel;
@property (nonatomic, weak)UIView * lineView;
//@property (nonatomic, weak)UITextView * textView;
@property(nonatomic,weak)UIWebView *webView;

@end

@implementation ResultViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = WHITE_COLOR;
    
    [self setupNav];
    [self setupUI];
}


- (void)setupNav{
    
    self.title = @"分析结果";
    
    UIButton * backButton = [[UIButton alloc] init];
    
    backButton.frame = CGRectMake(0, 0, 12 * SCREENH6, 20 * SCREENH6);
    [backButton setImage:[UIImage imageNamed:@"1返回"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backToView) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
    self.navigationItem.leftBarButtonItem = leftButton;
}



- (void)setupUI{
    
    UILabel * titleLabel = [UILabel new];
    
    titleLabel.text = [NSString stringWithFormat:@"<%@>的三彩分析",self.titleStr];
    titleLabel.textColor = BLACK_COLOR;
    titleLabel.font = [UIFont systemFontOfSize:20 * SCREENH6];
    
    self.titleLabel = titleLabel;
    
    [self.view addSubview:self.titleLabel];
    
    
    UIView * lineView = [UIView new];
    
    lineView.backgroundColor = ColorWithRGB(0xe6e6e6);//[UIColor lightGrayColor];
    
    self.lineView = lineView;
    
    [self.view addSubview:self.lineView];
    
//    UITextView *textView =[[UITextView alloc] init];
//    textView.backgroundColor= WHITE_COLOR;
//    textView.text = self.contentStr;
//    textView.textColor = [UIColor blackColor];
//    textView.editable = NO;
//    textView.font = [UIFont systemFontOfSize:15 * SCREENH6];
//
//    self.textView = textView;
//
//    [self.view addSubview:self.textView];
    
    UIWebView *webView = [[UIWebView alloc] init];
    webView.scalesPageToFit = YES;
//    webView.delegate = self;
    webView.backgroundColor = WHITE_COLOR;
    NSURL *urlPath = [NSURL fileURLWithPath:[NSBundle mainBundle].bundlePath];
    
    [webView loadHTMLString:self.contentStr baseURL:urlPath];
    
    self.webView = webView;
    
    [self.view addSubview:self.webView];
}


- (void)viewDidLayoutSubviews{
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.view).offset(10 * SCREENH6);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.mas_equalTo(self.view);
        make.height.mas_equalTo(1 * SCREENH6);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10 * SCREENH6);
    }];
    
//    [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.leading.mas_equalTo(self.view).offset(15 * SCREENH6);
//        make.trailing.mas_equalTo(self.view).offset(-15 * SCREENH6);
//        make.top.mas_equalTo(self.lineView.mas_bottom).offset(8 * SCREENH6);
//        make.bottom.mas_equalTo(self.view);
//    }];
    
    [self.webView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.view).offset(15 * SCREENH6);
        make.trailing.mas_equalTo(self.view).offset(-15 * SCREENH6);
        make.top.mas_equalTo(self.lineView.mas_bottom).offset(8 * SCREENH6);
        make.bottom.mas_equalTo(self.view);
    }];
}


- (void)backToView{
    
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
